<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="utf-8">
    <title>后台管理中心</title>
    <link rel="stylesheet" href="__STATIC__/admin/js/layui/css/layui.css">
    <link rel="stylesheet" href="__STATIC__/admin/js/bootstrap/css/bootstrap.css">
    <link href="__STATIC__/admin/css/AdminLTE.css" rel="stylesheet" type="text/css" />
    <link rel="stylesheet" href="__STATIC__/admin/js/layer/theme/default/layer.css">

</head>
<style>
    input[type=checkbox] {margin-right:2px;}
</style>

<script>

    function checkModel(v){
        $('.'+$(v).val()).each(function(){
            $(this).prop('checked',$(v).prop('checked'));
        })
    }

    function edit(){
        var params = {};
        params.id = $('#id').val();
        params.roleName = $('#roleName').val();
        var grant = [];
        $('.grant').each(function(){
            if($(this).prop('checked'))grant.push($(this).val());
        });
        params.grant = grant.join(',');
        if(grant.length==0){
            Plugins.Tips({title:'信息提示',icon:'error',content:'请至少选择一个权限!',timeout:1000});
            return;
        }

        $.post("{:url('Admin/auth/edit')}",params,function (data) {
            if(data == 1){
                layer.msg('添加成功', {icon: 1,time: 2000});
                setTimeout(function(){
                    window.location.href="{:url('admin/staff/staffList')}"
                },2000);
            }else{
                layer.msg('添加失败', {icon: 2});
            }
        })

    }
</script>
<body class="wst-page">
<form name="myform" method="post" id="myform" action="{:url('Admin/auth/edit')}" autocomplete="off">
    <input type='hidden' id='id' value=''/>
    <table class="table table-hover table-striped table-bordered wst-form">
        <tr>
            <th width='120' align='right'>角色名称<font color='red'>*</font>：</th>
            <td><input type='text' id='roleName' class="form-control wst-ipt" name="roleName" value='' maxLength='25'/></td>
        </tr>
        <tr>
            <th align='right'>权限列表<font color='red'>*</font>：</th>
            <td>
                <table width='100%'>
                    <tr>
                        <td  rowspan='6' valign='top' width='100'><label><input type='checkbox' class='chk' onclick='javascript:checkModel(this)' value='spgl'/>全选</label></td>
                    </tr>
                    <tr>
                        <td>
                            <label><input type='checkbox' class='chk grant spgl spfl' id='spfl_0' value='1'/>课程列表</label>
                            <label><input type='checkbox' class='chk grant spgl spfl' id='spfl_00' value='2'/>课程分类</label>
                            <label><input type='checkbox' class='chk grant spgl ppgl' id='ppgl_00' value='3'/>会员列表</label>
                            <label><input type='checkbox' class='chk grant spgl ppgl' id='ppgl_01' value='4'/>管理员列表</label>
                            <label><input type='checkbox' class='chk grant spgl ppgl' id='ppgl_02' value='5'/>订单列表</label>
                            <label><input type='checkbox' class='chk grant spgl ppgl' id='ppgl_03' value='6'/>文章列表</label>
                            <label><input type='checkbox' class='chk grant spgl splb' id='splb_0z0' value='7'/>角色列表</label>
                            <label><input type='checkbox' class='chk grant spgl splb' id='splb_024' value='8'/>角色添加</label>
                            <label><input type='checkbox' class='chk grant spgl splb' id='splb_041' value='9'/>角色添加</label>
                            <label><input type='checkbox' class='chk grant spgl splb' id='sp'       value='10'/>文章删除</label>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <label><input type='checkbox' class='chk grant spgl splb' id='splb_034' value='11'/>会员设置</label>
                            <label><input type='checkbox' class='chk grant spgl splb' id='splb_404' value='12'/>文章详情</label>
                            <label><input type='checkbox' class='chk grant spgl splb'  value='13'/>课程类删除</label>
                            <label><input type='checkbox' class='chk grant spgl splb'  value='14'/>添加课程表</label>
                            <label><input type='checkbox' class='chk grant spgl splb'  value='15'/>课程删除</label>
                            <label><input type='checkbox' class='chk grant spgl splb'  value='16'/>课程修改</label>
                            <label><input type='checkbox' class='chk grant spgl splb'  value='17'/>课程修改1</label>
                            <label><input type='checkbox' class='chk grant spgl splb'  value='18'/>上传图片</label>
                            <label><input type='checkbox' class='chk grant spgl splb'  value='19'/>上传视频</label>
                            <label><input type='checkbox' class='chk grant spgl splb'  value='20'/>添加课程</label>
                            <label><input type='checkbox' class='chk grant spgl splb'  value='21'/>课程新增</label>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <label><input type='checkbox' class='chk grant spgl splb'  value='22'/>订单删除</label>
                            <label><input type='checkbox' class='chk grant spgl splb'  value='23'/>订单修改</label>
                            <label><input type='checkbox' class='chk grant spgl splb'  value='24'/>订单修改1</label>
                            <label><input type='checkbox' class='chk grant spgl splb'  value='25'/>管理员修改</label>
                            <label><input type='checkbox' class='chk grant spgl splb'  value='26'/>管理添加</label>
                            <label><input type='checkbox' class='chk grant spgl splb'  value='27'/>管理删除</label>
                            <label><input type='checkbox' class='chk grant spgl splb'  value='28'/>会员查找</label>
                            <label><input type='checkbox' class='chk grant spgl splb'  value='29'/>会员查找1</label>
                            <label><input type='checkbox' class='chk grant spgl splb'  value='30'/>权限分配</label>
                            <label><input type='checkbox' class='chk grant spgl splb'  value='31'/>管理员恢复</label>
                            <label><input type='checkbox' class='chk grant spgl splb'  value='32'/>角色分配</label>
                            <label><input type='checkbox' class='chk grant spgl splb'  value='33'/>角色分配</label>
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
        <tr>
            <td colspan='2' style='padding-left:250px;'>
                <button type="button" class="btn btn-success" onclick="edit();">保&nbsp;存</button>
                <button type="button" class="btn btn-primary">返&nbsp;回</button>
            </td>
        </tr>
    </table>
</form>
</body>
<script src="__STATIC__/admin/js/html5shiv.min.js"></script>
<script src="__STATIC__/admin/js/respond.min.js"></script>
<script src="__STATIC__/admin/js/jquery.min.js" type="text/javascript"></script>
<script src="__STATIC__/admin/js/bootstrap/js/bootstrap.min.js"></script>
<script src="__STATIC__/admin/js/formValidator-4.1.3.js"></script>
<script src="__STATIC__/admin/js/common.js"></script>
<script src="__STATIC__/admin/js/plugins.js"></script>
<script src="__STATIC__/admin/js/layer/layer.js"></script>
</html>